package com.ljkj.blockpay.network.response;

import android.text.TextUtils;

import com.ljkj.blockpay.basedata.BaseModel;


public class BaseModelCallBack<T extends BaseModel> extends AbstractDisposableCallBack<T> {

    @Override
    public void onSuccess(T t) {
        if (t == null) {
            onFailed(HttpErrorCode.EMPTY, "");
            return;
        }

        if (!TextUtils.equals(t.code,HttpErrorCode.SUCCESS)) {
            onFailed(t.code, t.message);
            return;
        }
        onSafeSuccess(t);
    }

    protected void onSafeSuccess(T t) {
        // 推荐调用该方法
    }

    @Override
    protected void onSafeFailed(String code, String message) {
    }
}
